#ifndef __PROTO_H__
#define __PROTO_H__

#include <iostream>
#include <list>

const int LOGIN=1;
const int LOGOUT=2;
const int P2PTRANS=3;
const int GETALLUSERS=4;

const int SERVER_PORT=17630;
const int userNamePwdLen=31;

struct stLoginMessage
{
	char userName[userNamePwdLen];
	char password[userNamePwdLen];
};

struct stLogoutMessage
{
	char userName[userNamePwdLen];
};

// Client向服务器请求另外一个Client向自己方向发送UDP打洞消息
struct stP2PTranslateMessage
{
	char userName[userNamePwdLen];
};

struct stMessage
{
	int iMessageType;
	union _message
	{
		stLoginMessage loginmember;
		stLogoutMessage logoutmember;
		stP2PTranslateMessage translatemessage;
	}message;
};

struct stUserListNode
{
	char userName[userNamePwdLen];
	unsigned int ip;
	unsigned short port;
};

struct stServerToClientMessage
{
	int iMessageType;
	union _message
	{
		stUserListNode user;
	}message;
};

const int P2PMESSAGE = 100;
const int P2PMESSAGEACK = 101;
const int P2PSOMEONEWANTTOCALLYOU = 102;
const int P2PTRASH = 103;

struct stP2PMessage
{
	int iMessageType;
	int iStringLen;
	unsigned int ip;
	unsigned short Port;
};

typedef list<stUserListNode*> UserList;
#endif
